package com.example.demo.controller;

import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.Oneway;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
    UserMapper userMapper;


    @RequestMapping("/user")
    public Object getUser(HttpSession session){
        Map<Object, Object> map = new HashMap<>();
        String username = (String) session.getAttribute("username");
        System.out.println(userMapper.findAuthorityById(1).getName());
        if(username == null){
            map.put("code",1);
        }
        else {
            map.put("code",0);
            map.put("username", username);
        }
        return map;
    }
}
